const { defineConfig } = require('vite')
import { resolve } from 'path'

const libName = 'jslib'
module.exports = defineConfig({
  build: {
    sourcemap: false,
    lib: {
      entry: resolve(__dirname, 'src/main.js'),
      name: libName,
      fileName: (format) => `${libName}.${format}.js`,
      // formats: ['es', 'cjs', 'umd', 'iife'],
    }
  },
  server: {
    open: '/example/index.html'
  },
  define: {
    // 'process.env': process.env /* 危险，会注入所有环境变量，必要的话建议一个个引入 */
    // 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
    // 'process.env.MY_API_KEY': JSON.stringify('safe-public-key'),
  }
})